package com.wyc.service.mode.builder;

import java.util.ArrayList;

public abstract class CarModel {
    private ArrayList<String> sequence = new ArrayList<>();

    protected abstract void start();
    protected abstract void stop();
    protected abstract void alarm();
    protected abstract void engineBoom();

    final public void run(){
        for (int i = 0; i < this.sequence.size(); i++) {
            String action = this.sequence.get(i);
            if (action.equalsIgnoreCase("start")){
                this.start();
            } else if (action.equalsIgnoreCase("stop")){
                this.stop();
            } else if (action.equalsIgnoreCase("alarm")){
                this.alarm();
            } else if (action.equalsIgnoreCase("engine boom")){
                this.engineBoom();
            }
        }
    }

    final public void setSequence(ArrayList actions){
        this.sequence = actions;
    }
}
